package com.gsbelarus.gedemin.salary.ui;

import android.content.Context;
import android.graphics.Rect;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.gsbelarus.gedemin.salary.adapter.PayslipGeneralAdapter;

public class PayslipGeneralDecoration extends RecyclerView.ItemDecoration {

    private int space;

    public PayslipGeneralDecoration(Context context, float dp) {
        space = (int) (dp * context.getResources().getDisplayMetrics().density);
    }

    public PayslipGeneralDecoration(Context context, int resource) {
        space = context.getResources().getDimensionPixelSize(resource);
    }

    @Override
    public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
        super.getItemOffsets(outRect, view, parent, state);

        if (parent.getAdapter().getItemViewType(parent.getChildAdapterPosition(view)) != PayslipGeneralAdapter.ItemType.SUB_ITEM.ordinal())
            return;

        outRect.top = space;
        outRect.bottom = space;
    }
}
